function ajax(url) {
  return new Promise((resolve, reject) => {
    let xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.responseType = 'json';
    xhr.onload = () => {
      if (xhr.status === 200) resolve(xhr.response);
      else reject(new Error(xhr.statusText));
    }
    xhr.send();
  })
}

function* main() {
  const person = yield ajax('./part1/person.json');
  console.log(person);
  const person2 = yield ajax('./part1/person2.json');
  console.log(person2);
}

const g = main();
const result = g.next();
result.value.then(data => {
  const re2 = g.next(data);
  re2.value.then(data2 => {
    g.next(data2);
  });
})
